<template>
	<view>
		<view>我是index2</view>
		<view>msg:{{msg}}</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				msg: '',
				topic: 'sys/b69D7OHdY8P7C6Fp/7C:A7:B0:E7:0C:B9/thing/event/property/post/requestLock'
			}
		},
		onShow() {
			this.btn1();
		},
		onBackPress(e){
			  // console.log("监听返回按钮事件",e);
			  this.$store.getters.getState.client.unsubscribe(this.topic, () => {
			  	console.log("index2 | 退订主题成功");
			  });
			  uni.navigateTo({
			    url:'../index/index'
			  });
			 // 此处一定要return为true，否则页面不会返回到指定路径
			return true;
		},
		methods: {
			btn1() {
				this.msg = '';
				this.$store.getters.getState.client.subscribe(this.topic, () => {
					console.log("index2 | 订阅主题成功");
					// this.msg = this.$store.getters.getState.message;
					// console.log("state.msg:", this.$store.getters.getState.message);
				});
			}
		}
	}
</script>

<style>

</style>
